package com.shigen.demo.atguigu;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * 阻塞队列
 *
 * @author shigenfu
 * @date 2022/5/22 7:35 下午
 */
public class BlockingQueueDemo {

  public static void main(String[] args) throws InterruptedException {

    BlockingQueue<String> blockingQueue = new ArrayBlockingQueue<>(3);
    System.out.println(blockingQueue.add("a"));
    System.out.println(blockingQueue.add("b"));
    System.out.println(blockingQueue.add("c"));
    // Exception in thread "main" java.lang.IllegalStateException: Queue full
    // System.out.println(blockingQueue.add("d"));

    System.out.println(blockingQueue.remove());


  }
}
